﻿using System;
using System.Collections.Generic;
using System.Text;
using WeatherApp.Base;

namespace WeatherApp
{
    /// <summary>
    ///恋爱指数公告板
    ///小于1°C指数为10
    ///1~15°C指数为30
    ///15~30°C指数为100
    ///30~45°C指数为60
    ///大于45°C；还想着恋爱？赶紧找地方避暑，还想啥呢老弟
    /// </summary>
   public class HaveaLoveaAffairExponent : IObserver, IDisplayElement
    {
        private float exponent = 0.0f;
        public HaveaLoveaAffairExponent(ISubject weatherData)
        {
            weatherData.RegisterObserver(this);
        }
        public void Display()
        {
            Console.WriteLine($"HaveaLoveaAffairExponent： 恋爱指数为：{exponent}");
        }
        public void Update(float temp, float humidity, float pressure)
        {
            exponent = ComputeHeatIndex(temp);
            Display();
        }
        private float ComputeHeatIndex(float t)
        {
            if (t < 1)
            {
                return 10f;
            }
            else if (t < 15 && t >= 1)
            {
                return 30f;
            }
            else if (t < 30 && t >= 15)
            {
                return 100f;
            }
            else if (t >= 30 && t < 45)
            {
                return 60f;
            }
            else
            {
                return 0f;
            }

        }

    }
}
